package cn.tradewin.pmp.pages.test;

import org.apache.tapestry5.PersistenceConstants;
import org.apache.tapestry5.annotations.Log;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.internal.translator.NumericTranslatorSupport;
import org.apache.tapestry5.ioc.annotations.Inject;
import org.slf4j.Logger;

public class AugmentingTranslators {

	@Inject
	Logger log;

	@Inject
	private NumericTranslatorSupport numericTranslatorSupport;

	@Property
	@Persist(value=PersistenceConstants.FLASH)
	private int primitiveWithZeroSuppressed;

	@Log
	String onToClientFromPrimitiveWithZeroSuppressed() {
		return primitiveWithZeroSuppressed + "_yuan";
	}

	@Log
	Object onParseClientFromPrimitiveWithZeroSuppressed(String input) {
		// primitiveWithZeroSuppressed = Integer.parseInt(input.substring(0,
		// input.indexOf("_")));
		input = input.substring(0, input.indexOf("_"));
		return Integer.parseInt(input);
	}
	
	@Log
	void onSuccess() {
		log.debug("primitiveWithZeroSuppressed = " + primitiveWithZeroSuppressed);
	}

}
